//
//  BKMyOrderCellHeaderView.m
//  bestkeep
//
//  Created by Mr. Wu on 16/12/6.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKMyOrderCellHeaderView.h"

#import "BK_OD_Color.h"
#import "BK_OD_Tool.h"


/*
 * 全部订单  XX发货
 */
@implementation BKMyOrderCellHeaderView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = RGB(242, 242, 242);
        [self initView];
    }
    return self;
}
- (void)initView{
    
    /**
     *  背景
     */
    _bgView = [UIView new];
    _bgView.backgroundColor = [UIColor whiteColor];
    [self addSubview:_bgView];
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.bottom.mas_equalTo(self.mas_bottom);
        make.top.mas_equalTo(self.mas_top).offset(10);
    }];
    
    /**
     *  位置图片
     */
    _ImgV_Address=[[UIImageView alloc]init];
    _ImgV_Address.backgroundColor=[UIColor clearColor];
    [self addSubview:_ImgV_Address];
    _ImgV_Address.image=[UIImage imageNamed:@"订单-发货地icon"];
    [_ImgV_Address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_bgView.mas_centerY).offset(0);
        make.left.mas_equalTo(_bgView.mas_left).offset(ApplicationBackGauge);
        make.height.equalTo(@(12));
        make.width.equalTo(@(14));
    }];
    
    /**
     *  发货地址
     */
    _address = [UILabel new];
    _address.backgroundColor = [UIColor clearColor];
    _address.textColor = kOrderBlack1;
    _address.text = @"---发货";
    _address.font = [UIFont systemFontOfSize:14];
    [_bgView addSubview:_address];
    
    [_address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_bgView.mas_centerY).offset(0);
        make.left.mas_equalTo(_ImgV_Address.mas_right).offset(10);
    }];
    
    /**
     *   箭头
     */
    _lab_Arrow = [[UILabel alloc] initWithFrame:CGRectZero];
    _lab_Arrow.font=[UIFont fontWithName:@"iconfont" size:12.0];
    _lab_Arrow.textColor = HexColor(0x999999);
    _lab_Arrow.text = @"\U0000e618";
    [self addSubview:_lab_Arrow];
    [_lab_Arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_address.mas_right).offset(10);
        make.centerY.equalTo(_address.mas_centerY);
        make.height.equalTo(@(15));
        make.width.equalTo(@(15));
        
    }];
    _lab_Arrow.hidden=YES;
    
    /**
     *  发货状态
     */
    _goodsStatus = [UILabel new];
    _goodsStatus.textColor = kOrderLightGrey1;
    _goodsStatus.text = @"加载中...";
    _goodsStatus.backgroundColor = [UIColor whiteColor];
    _goodsStatus.font = [UIFont systemFontOfSize:14];
    [_bgView addSubview:_goodsStatus];
    [_goodsStatus mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_bgView.mas_centerY).offset(0);
        make.right.mas_equalTo(_bgView.mas_right).offset(-ApplicationBackGauge);
    }];
    
    /**
     *  底部横线
     */
    _liven =[UIView new];
    _liven.backgroundColor=RGB(221, 221, 221);
    [_bgView addSubview:_liven];
    [_liven mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_bgView.mas_left);
        make.right.equalTo(_bgView.mas_right);
        make.height.equalTo(@(0.7));
        make.bottom.equalTo(_bgView.mas_bottom);
    }];
    _liven.hidden=YES;
    
    
    _lab_predict_FaHuo=[UILabel new];
    _lab_predict_FaHuo.textColor = RGB(136, 136, 136);
    _lab_predict_FaHuo.text = @"(加载中...)";
    _lab_predict_FaHuo.backgroundColor = [UIColor clearColor];
    _lab_predict_FaHuo.font = [UIFont systemFontOfSize:10];
    [_bgView addSubview:_lab_predict_FaHuo];
    [_lab_predict_FaHuo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_bgView.mas_centerY).offset(0);
        make.left.mas_equalTo(_address.mas_right).offset(0);
    }];
    _lab_predict_FaHuo.hidden=YES;
    
}

//-(void)setCenM:(CenterModel *)cenM{
    

//}
-(void)fillData:(id)data{
    BK_My_Order_SectionModel *section = data;
    BK_My_Order_rows_Model *cenM= section.model_Order_rows;
    /*
     
     订单状态：
     01，待支付                     去付款
     02，已支付（待发货）    取消订单
     03，已发货                     查看物流 ，收货确认
     04，交易成功                  删除订单，查看物流，去评价
     05，交易关闭
     06，已取消   //申请退款中;
     07，已退款  //退款成功; 
     
     */
    
        _address.text = [NSString stringWithFormat:@"%@发货", cenM.deliver] ;
    
        if ([cenM.status isEqualToString:@"01"]) {
            _goodsStatus.textColor = kOrderBKGreen;
        }
        if ([cenM.status isEqualToString:@"02"]) {
            _goodsStatus.textColor = kOrderBKGreen;
        }
        if ([cenM.status isEqualToString:@"04"]) {
            _goodsStatus.textColor = kOrderBKGreen;
        }
    
        if ([cenM.status isEqualToString:@"03"]) {
            _goodsStatus.textColor = kOrderBKGreen;
        }
    
        if([cenM.status_name rangeOfString:@"待收货"].location !=NSNotFound){
    
            _goodsStatus.textColor = kOrderBKGreen;
        }else if([cenM.status_name rangeOfString:@"待发货"].location !=NSNotFound){
    
            _goodsStatus.textColor = kOrderBKGreen;
        }else  if([cenM.status_name rangeOfString:@"交易成功"].location !=NSNotFound){
            
        }            
            else if([cenM.status_name rangeOfString:@"申请退款中"].location !=NSNotFound){
            _goodsStatus.textColor = kOrderBKGreen;
        }
        else if([cenM.status_name rangeOfString:@"退款成功"].location !=NSNotFound){
            _goodsStatus.textColor = kOrderBKGreen;
        }
        _goodsStatus.text = cenM.status_name;
        

    
}
@end
//
//@implementation BKMyOrderRecommnedHeader
//- (instancetype)initWithFrame:(CGRect)frame{
//    self = [super initWithFrame:frame];
//    if (self) {
//        [self initView];
//    }
//    return self;
//}
//
//-(void)initView{
//    
//    //    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 16, 16)];
//    //    [centerView addSubview:leftImageView];
//    //    leftImageView.image = [UIImage imageNamed:@"BKSCRecommend"];
//    UILabel *recommendLabel = [[UILabel alloc] initWithFrame:CGRectZero];
//    recommendLabel.text = @"为你推荐";
//    recommendLabel.font = [UIFont systemFontOfSize:15];
//    recommendLabel.textColor = RGB(68, 68, 68);
//    [self addSubview:recommendLabel];
//    [recommendLabel setTextAlignment:NSTextAlignmentCenter];
//    
//    UIView *leftView = [[UIView alloc]init];
//    leftView.backgroundColor = RGB(217, 218, 219);
//    [self addSubview:leftView];
//    
//    UIView *rightView = [[UIView alloc]init];
//    rightView.backgroundColor = RGB(217, 218, 219);
//    [self addSubview:rightView];
//    
//    [recommendLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(self.mas_centerX);
//        make.width.mas_equalTo(63);
//        
//    }];
//    
//    [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.mas_equalTo(recommendLabel.mas_centerY);
//        make.left.mas_equalTo(self.mas_left).offset(5);
//        make.right.mas_equalTo(recommendLabel.mas_left).offset(-5);
//        make.height.mas_equalTo(1);
//    }];
//    
//    [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.mas_equalTo(recommendLabel.mas_centerY);
//        make.right.mas_equalTo(self.mas_right).offset(-5);
//        make.left.mas_equalTo(recommendLabel.mas_right).offset(5);
//        make.height.mas_equalTo(1);
//    }];
//    
//    
//}
//
//
//
//
//@end







